<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>OpenLayers v8.2.0 API - Module: ol/style/Text</title>
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
        crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.2/css/fontawesome.min.css"
        crossorigin="anonymous">
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.2/css/solid.css" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.2/css/brands.css" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="styles/prettify-tomorrow.css">
    <link rel="stylesheet" type="text/css" href="styles/jaguar.css">
    <link rel="stylesheet" type="text/css" href="styles/carbon.css">
    <link rel="stylesheet" type="text/css" href="/theme/ol.css">
    <link rel="stylesheet" type="text/css" href="/theme/site.css">
</head>

<body>
    <header class="navbar navbar-expand-sm navbar-dark mb-3 px-3 py-0 fixed-top" role="navigation">
        <a class="navbar-brand" href="/"><img src="/theme/img/logo-dark.svg" width="70" height="70"
                alt="">&nbsp;OpenLayers</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#olmenu"
            aria-controls="olmenu" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <!-- menu items that get hidden below 768px width -->
        <nav class="collapse navbar-collapse" id="olmenu">
            <ul class="nav navbar-nav ms-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="docdropdown" role="button"
                        data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Docs</a>
                    <div class="dropdown-menu dropdown-menu-end mb-3" aria-labelledby="docdropdown">
                        <a class="dropdown-item" href="/doc/">Docs</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="/doc/quickstart.html"><i
                                class="fa fa-check fa-fw me-2 fa-lg"></i>快速入门</a>
                        <a class="dropdown-item" href="/doc/faq.html"><i
                                class="fa fa-question fa-fw me-2 fa-lg"></i>FAQ</a>
                        <a class="dropdown-item" href="/doc/tutorials/"><i
                                class="fa fa-book fa-fw me-2 fa-lg"></i>Tutorials</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="https://stackoverflow.com/questions/tagged/openlayers"><i
                                class="fab fa-stack-overflow fa-fw me-2"></i>Ask a Question</a>
                    </div>
                </li>
                <li class="nav-item"><a class="nav-link" href="/en/latest/examples/">Examples</a></li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="apidropdown" role="button"
                        data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-sitemap me-1"></i>API
                    </a>
                    <div class="dropdown-menu dropdown-menu-end mb-3" aria-labelledby="apidropdown">
                        <a class="dropdown-item" href="/en/latest/apidoc/"><i
                                class="fa fa-sitemap fa-fw me-2 fa-lg"></i>v8.2.0
                            (latest)</a </div>
                </li>
            </ul>
        </nav>
    </header>

    <div class="container-fluid">
        <div id="wrap" class="row">
            <div class="navigation col-md-4 col-lg-3">
                <div class="search-wrapper">
                    <div class="search">
                        <input id="search" type="text" autocomplete="off" class="form-control input-sm"
                            placeholder="Search Documentation">
                    </div>
                </div>
                <div class="navigation-list-wrapper">
                    <ul class="navigation-list search-empty">
                        <li class="item item-module toggle-manual toggle-manual-show"
                            data-longname="module:ol/style/Text" data-name="ol/style/text">
                            <span class="title toggle">
                                <span class="fa fa-plus me-2 mt-1"></span>
                                <span><a href="module-ol_style_Text.html">ol​/style​/Text</a></span>
                            </span>
                            <div class="member-list" data-type="typedefs">
                                <span class="subtitle">Typedefs</span>
                                <ul>
                                    <li data-name="options"><a href="module-ol_style_Text.html#~Options">Options</a>
                                    <li data-name="textjustify"><a
                                            href="module-ol_style_Text.html#~TextJustify">TextJustify</a>
                                    <li data-name="textplacement"><a
                                            href="module-ol_style_Text.html#~TextPlacement">TextPlacement</a>
                                </ul>
                            </div>
                        <li class="loading">Loading …
                    </ul>
                </div>
            </div>

            <div class="main col-md-8 col-lg-9">
                <h1 class="page-title" data-filename="module-ol_style_Text.html">Module: ol/style/Text</h1>
                <div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
                    <button id="latest-dismiss" type="button" class="btn-close" data-bs-dismiss="alert"
                        aria-label="Close"></button>
                    This documentation is for OpenLayers v<span id="package-version">8.2.0</span>. The <a
                        id="latest-link" href="#" class="alert-link">latest</a> is v<span id="latest-version"></span>.
                </div>




                <section class="content">

                    <header>
                        <h2 class="my-3">ol/style/Text
                        </h2>
                        <br>




                        <div class="row p-3 ">
                            <!-- <div id="ad" class="col-lg-5 order-2 align-self-center border rounded bg-light ">
                                <script async type="text/javascript"
                                    src="https://cdn.carbonads.com/carbon.js?serve=CE7DV53U&placement=openlayersorg"
                                    id="_carbonads_js"></script>
                            </div> -->

                        </div>
                    </header>

                    <article>
                        <div class="container-overview">






                            <dl class="details">





















                            </dl>




                        </div>










                        <h3 class="subsection-title">Classes</h3>

                        <dl>
                            <dt><a href="module-ol_style_Text-Text.html">Text</a></dt>
                            <dd></dd>
                        </dl>











                        <h3 class="subsection-title">Type Definitions</h3>

                        <dl>

                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id="~Options">
                                    </div>
                                    <h4 class="name">
                                        Options<span class="type-signature type object">{Object}</span>


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">



                                <dl class="details">


                                    <h5 class="subsection-title">Properties:</h5>

                                    <dl>

                                        <table class="props">
                                            <thead>
                                                <tr>

                                                    <th>Name</th>


                                                    <th>Type</th>

                                                    <th class="last">Description</th>
                                                </tr>
                                            </thead>

                                            <tbody>


                                                <tr>

                                                    <td class="name"><code>font</code></td>


                                                    <td class="type">


                                                        <span class="param-type">string</span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>字体样式作为CSS字体值， 参考：
                                                            <a
                                                                href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font">https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font</a>.
                                                            默认是<code>'10px sans-serif'</code>
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>maxAngle</code></td>


                                                    <td class="type">


                                                        <span class="param-type">number</span>



                                                        <br>(defaults to Math.PI/4)


                                                    </td>

                                                    <td class="description last">
                                                        <p>当 <code>放置位置(placement)</code>设置为'<code>'line'</code>,允许相邻字符之间的最大角度。
                                                            预期值为弧度，默认为45°
                                                            (<code>Math.PI / 4</code>).</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>offsetX</code></td>


                                                    <td class="type">


                                                        <span class="param-type">number</span>



                                                        <br>(defaults to 0)


                                                    </td>

                                                    <td class="description last">
                                                        <p>像素中的水平文本偏移量。正值将使文本向右移动。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>offsetY</code></td>


                                                    <td class="type">


                                                        <span class="param-type">number</span>



                                                        <br>(defaults to 0)


                                                    </td>

                                                    <td class="description last">
                                                        <p>像素中的垂直文本偏移量。正值将使文本向下移动。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>overflow</code></td>


                                                    <td class="type">


                                                        <span class="param-type">boolean</span>



                                                        <br>(defaults to false)


                                                    </td>

                                                    <td class="description last">
                                                        <p>对于多边形标签或当<code>placement</code><code>'line'</code>时，允许文本超出多边形在标签位置或它跟随的路径的长度的宽度。
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>placement</code></td>


                                                    <td class="type">


                                                        <span class="param-type"><a
                                                                href="module-ol_style_Text.html#~TextPlacement">TextPlacement</a></span>



                                                        <br>(defaults to 'point')


                                                    </td>

                                                    <td class="description last">
                                                        <p>文本放置位置</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>repeat</code></td>


                                                    <td class="type">


                                                        <span class="param-type">number</span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>重复间隔。当设置时，文本将在此间隔内重复，该间隔指定两个文本锚点之间的像素距离。仅当<code>placement</code>设置为<code>'line'</code>时可用。覆盖
                                                            'textAlign'.</p>
                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>scale</code></td>


                                                    <td class="type">


                                                        <span class="param-type">number</span>
                                                        |

                                                        <span class="param-type"><a
                                                                href="module-ol_size.html#~Size">Size</a></span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>缩放比例。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>rotateWithView</code></td>


                                                    <td class="type">


                                                        <span class="param-type">boolean</span>



                                                        <br>(defaults to false)


                                                    </td>

                                                    <td class="description last">
                                                        <p>文本是否随视图旋转。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>rotation</code></td>


                                                    <td class="type">


                                                        <span class="param-type">number</span>



                                                        <br>(defaults to 0)


                                                    </td>

                                                    <td class="description last">
                                                        <p>旋转角度（以弧度为单位）（正旋转为顺时针）。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>text</code></td>


                                                    <td class="type">


                                                        <span class="param-type">string</span>
                                                        |

                                                        <span class="param-type">Array.&lt;string></span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>扩展内容或富文本内容。对于纯文本，提供一个字符串，其中可以包含换行符(<code>\n</code>)。对于富文本，提供一个文本/字体元组的数组。
                                                            一个元组由要渲染的文本和要使用的字体 (或 <code>''</code>
                                                            使用文本样式的字体)组成。换行符必须是单独的元组(即
                                                            <code>'\n', ''</code>).
                                                            <strong>示例：</strong>
                                                            <code>['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']</code>
                                                            将产生 &quot;<strong>foo</strong> <em>bar</em> baz&quot;.
                                                            <strong>注意:</strong>对于：
                                                            <code>placement: 'line'</code>或直接渲染API，不支持富文本。
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>textAlign</code></td>


                                                    <td class="type">


                                                        <span class="param-type">CanvasTextAlign</span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>文本对齐方式。可能的值： <code>'left'</code>,
                                                            <code>'right'</code>, <code>'center'</code>,
                                                            <code>'end'</code>
                                                            or
                                                            <code>'start'</code>。对于<code>placement: 'point'</code>，默认值为
                                                            <code>'center'</code>。对于
                                                            <code>placement: 'line'</code>默认值是让渲染器选择一个不超过
                                                            <code>maxAngle</code>的放置位置。
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>justify</code></td>


                                                    <td class="type">


                                                        <span class="param-type"><a
                                                                href="module-ol_style_Text.html#~TextJustify">TextJustify</a></span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>文本框内的文本对齐方式。如果未设置，则文本将向 <code>textAlign</code>
                                                            锚点对齐。否则，使用选项<code>'left'</code>,
                                                            <code>'center'</code>, or <code>'right'</code> 在文本框内对齐文本。
                                                            <strong>注意:</strong>对于立即渲染和放置位置为'line'的情况，将忽略justify。
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>textBaseline</code></td>


                                                    <td class="type">


                                                        <span class="param-type">CanvasTextBaseline</span>



                                                        <br>(defaults to 'middle')


                                                    </td>

                                                    <td class="description last">
                                                        <p>文本基线。可能的值： <code>'bottom'</code>,
                                                            <code>'top'</code>, <code>'middle'</code>,
                                                            <code>'alphabetic'</code>,
                                                            <code>'hanging'</code>, <code>'ideographic'</code>.
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>fill</code></td>


                                                    <td class="type">


                                                        <span class="param-type"><a
                                                                href="module-ol_style_Fill-Fill.html">Fill</a></span>
                                                        |

                                                        <span class="param-type">null</span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>填充样式。如果没有提供，我们将使用深色填充样式（#333）。指定null表示不填充。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>stroke</code></td>


                                                    <td class="type">


                                                        <span class="param-type"><a
                                                                href="module-ol_style_Stroke-Stroke.html">Stroke</a></span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>边样式。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>backgroundFill</code></td>


                                                    <td class="type">


                                                        <span class="param-type"><a
                                                                href="module-ol_style_Fill-Fill.html">Fill</a></span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>当放置位置为<code>'point'</code>时，文本背景的填充样式。默认不填充。
                                                        </p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>backgroundStroke</code></td>


                                                    <td class="type">


                                                        <span class="param-type"><a
                                                                href="module-ol_style_Stroke-Stroke.html">Stroke</a></span>

                                                        | undefined


                                                    </td>

                                                    <td class="description last">
                                                        <p>当放置位置为'point'时，文本背景的描边样式。默认不描边。</p>

                                                    </td>
                                                </tr>



                                                <tr>

                                                    <td class="name"><code>padding</code></td>


                                                    <td class="type">


                                                        <span class="param-type">Array.&lt;number></span>



                                                        <br>(defaults to [0, 0, 0, 0])


                                                    </td>

                                                    <td class="description last">
                                                        <p>用于消除混乱和背景的文本周围的像素填充。数组中值的顺序为<code>[top, right, bottom, left]</code>.
                                                        </p>

                                                    </td>
                                                </tr>


                                            </tbody>
                                        </table>
                                    </dl>






















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id="~TextJustify">
                                    </div>
                                    <h4 class="name">
                                        TextJustify<span class="type-signature type 'left'">{'left'}</span> <span
                                            class="type-signature type 'center'">{'center'}</span> <span
                                            class="type-signature type 'right'">{'right'}</span>


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id="~TextPlacement">
                                    </div>
                                    <h4 class="name">
                                        TextPlacement<span class="type-signature type 'point'">{'point'}</span> <span
                                            class="type-signature type 'line'">{'line'}</span>


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>Default text placement is <code>'point'</code>. Note that
                                        <code>'line'</code> requires the underlying geometry to be a <a
                                            href="module-ol_geom_LineString-LineString.html"><code>LineString</code></a>,
                                        <a href="module-ol_geom_Polygon-Polygon.html"><code>Polygon</code></a>, <a
                                            href="module-ol_geom_MultiLineString-MultiLineString.html"><code>MultiLineString</code></a>
                                        or
                                        <a
                                            href="module-ol_geom_MultiPolygon-MultiPolygon.html"><code>MultiPolygon</code></a>.
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>

                        </dl>



                    </article>

                </section>




            </div>
        </div>
    </div>
    <script>prettyPrint();</script>
    <script src="scripts/linenumber.js"></script>
    <script src="scripts/main.js"></script>
</body>

</html>